<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <form action="">
        <input type="checkbox" name="" id="">你哈 <br>
        <input type="checkbox" name="" id="">你哈 <br>
        <input type="checkbox" name="" id="">你哈 <br>
        <input type="checkbox" name="" id="">你哈 <br>
        <input type="checkbox" name="" id="">你哈 <br>
        <input type="checkbox" name="" id="">你哈 <br>
        <input type="checkbox" name="" id="">你哈 <br>
        <input type="checkbox" name="" id="">你哈 <br>
        <input type="checkbox" name="" id="">你哈 <br>
    </form>
    <button id="quan">全选</button>
    <button id="qu">反选</button>
    <input type="checkbox">
</body>

</html>
<script>
    var put = document.getElementsByTagName('input');
    console.log(put);
    var quan = document.getElementById('quan');
    var qu = document.getElementById('qu');
    quan.onclick = function() {
        for (var i = 0; i < put.length; i++) {
            put[i].checked = true;
        }

    }
    qu.onclick = function() {
        for (var i = 0; i < put.length; i++) {
            put[i].checked = !put[i].checked;
        }

    }
</script>